const fs = require('fs');

fs.readFile('./data.json', 'utf-8', (err, data) => {
  let newData = {};
  newData.data = JSON.parse(data).heros.map((el, index) => {
    return {
      id: index,
      name: el.cname,
      title: el.title,
      add_time: new Date().getTime()
    };
  });
  fs.writeFile('./data.json', JSON.stringify(newData), err1 => {
    console.log('写入成功')
  })
})